package com.ruoyi.logistic.controller;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.logistic.domain.NetworkCustomerManageDetail;
import com.ruoyi.logistic.domain.PageDate;
import com.ruoyi.logistic.domain.PageInfo;
import com.ruoyi.logistic.domain.vo.NetworkCustomerManageDetailVo;
import com.ruoyi.logistic.service.NetworkCustomerManageDetailService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.parameters.P;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/network/customerManageDetail")
@RestController
@Api(tags = "网点财务_客户经营_运单明细")
public class NetworkCustomerManageDetailController {
    @Autowired
    private NetworkCustomerManageDetailService networkCustomerManageDetailService;

    @ApiOperation("显示客户经营运单明细")
    @GetMapping("/selectAll")
    public R selectAll(PageDate pageDate){
        List<NetworkCustomerManageDetail> customerManageDetailList = networkCustomerManageDetailService.selectAll(pageDate);
        if (customerManageDetailList == null || customerManageDetailList.size() == 0){
            return R.fail("暂无数据");
        }else {
            return R.ok(PageInfo.info(customerManageDetailList));
        }
    }
    @ApiOperation("添加客户经营运单明细")
    @PostMapping("/insert")
    public R insert(@RequestBody NetworkCustomerManageDetail networkCustomerManageDetail){
        return R.ok(networkCustomerManageDetailService.insert(networkCustomerManageDetail));
    }

    @ApiOperation("修改客户经营运单明细")
    @PostMapping("/update")
    public R update(@RequestBody NetworkCustomerManageDetail networkCustomerManageDetail){
        return R.ok(networkCustomerManageDetailService.update(networkCustomerManageDetail));
    }

    @ApiOperation("修改客户经营运单明细")
    @PostMapping("/deleteById")
    public R deleteById(Integer id){
        return R.ok(networkCustomerManageDetailService.deleteById(id));
    }

    @ApiOperation("搜索客户经营运单明细")
    @PostMapping("/search")
    public R search(@RequestBody NetworkCustomerManageDetailVo networkCustomerManageDetailVo){
        List<NetworkCustomerManageDetail> customerManageDetailList = networkCustomerManageDetailService.search(networkCustomerManageDetailVo);
        if (customerManageDetailList == null || customerManageDetailList.size() == 0){
            return R.fail("暂无数据");
        }else {
            return R.ok(PageInfo.info(customerManageDetailList));
        }
    }
}
